package com.google.gwt.indexeddb.client;

import com.google.gwt.core.client.JavaScriptObject;

/**
 * The IDBFactory interface of the IndexedDB API provides a mechanism for applications to
 * asynchronously access capabilities of indexed databases.
 * 
 */

public class IDBFactory extends JavaScriptObject {
  
  protected IDBFactory() {
  }

  /**
   * Returns <code>true</code> if the IDBDatabase API is supported on the running platform.
   */
  public final native boolean isSupported() /*-{
		return typeof ($wnd.indexedDB || $wnd.mozIndexedDB || $wnd.webkitIndexedDB) != "undefined";
  }-*/;

  /**
   * Call this method to request opening a connection to a database. The method returns immediately,
   * and performs the opening operation in a different thread.
   * 
   * @see <a href="http://www.w3.org/TR/IndexedDB/#widl-IDBFactory-open">W3C Web IndexedDB -
   *      IDBFactory-open</a>
   * @param strName (Short) The name of the database.
   * @return A request object on which subsequent events related to this request are fired.
   */
  public final native IDBRequest open(String strName) /*-{
		return this.open(strName);
  }-*/;

  /**
   * Creates a async handler to a IDBRequest instance.
   * 
   * @see <a href="http://www.w3.org/TR/IndexedDB/#widl-IDBFactory-deleteDatabase">W3C Web IndexedDB
   *      - IDBFactory - deleteDatabase</a>
   * @param strName (Short) name of the database
   * @return a IDBRequest instance
   */
  public final native IDBRequest deleteDatabase(String strName) /*-{
		return this.deleteDatabase(strName);
  }-*/;

}
